package com.myhdg.school.fragments;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.myhdg.school.R;

import java.util.List;

public class FragmentAdapter extends FragmentPagerAdapter {
    private Context mContext;
    private List<BaseFragment> mFragment;
    private String[] tabsId = {"课程表", "校园", "发现"};
    private int[] tabsImage = {R.drawable.bg_curriculum, R.drawable.bg_school, R.drawable.bg_find};

    public FragmentAdapter(FragmentManager fm, List<BaseFragment> fragment, Context context) {
        super(fm);
        this.mFragment = fragment;
        this.mContext = context;
    }

    public View getView(int pos) {
        @SuppressLint("InflateParams") View view = LayoutInflater.from(mContext).inflate(R.layout.bottom_item, null);
        TextView itemId = view.findViewById(R.id.itemId);
        ImageView itemImage = view.findViewById(R.id.itemImage);
        itemId.setText(tabsId[pos]);
        itemImage.setImageResource(tabsImage[pos]);
        return view;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragment.get(position);
    }

    @Override
    public int getCount() {
        return tabsId.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabsId[position];
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }
}
